<?php
/*
 * Module 的通用方法
 * Module 需要有属性值 $model
 */
trait Lib_BaseTraitsModule {

    function getItemById($id,$cache = false,$pk = 'id'){
        return $this->model->getItemById($id,$cache,$pk);
    }

    function deleteItemById($id,$pk = 'id'){
        return $this->model->deleteItemById($id,$pk);
    }

    function getOne($fields = array(),$where = array(),$cache = false){
        return $this->model->getOne($fields,$where,$cache);
    }

    function getAll($fields = array(),$cache = false){
        return $this->model->getAll($fields,$cache);
    }

    function singleUpdate($saveData,$pk = 'id'){
        return $this->model->singleUpdate($saveData,$pk);
    }

    function singleInsert($saveData,$auto_increase = true,$pk = 'id'){
        return $this->model->singleInsert($saveData,$auto_increase,$pk);
    }

    function getAllBySearch($fields = array(),$search = array(),$cache = false,$count=false){
        return $this->model->getAllBySearch($fields,$search,$cache,$count);
    }
    function getGroupTotalBySearch($fields = array(),$search = array(),$cache = false){
        return $this->model->getGroupTotalBySearch($fields,$search,$cache);
    }

    /**
     * 开始事务
     * @param unknown $id
     */
    function beginTransaction(){
        return $this->model->beginTransaction();
    }


    /**
     * 回滚
     * @param unknown $id
     */
    function rollback(){
        return $this->model->rollback();
    }


    /**
     * 提交事务
     * @param unknown $id
     */
    function commit(){
        return $this->model->commit();
    }

}